<template>
  <div class="hotArea">
    <div class="card-title">
      <div class="title-font">当季<span class="orange">热推</span></div>
    </div>
    <div class="top5">
      <div class="follow">
        <div class="header">
          <img
            src="https://webresource.c-ctrip.com/ares2/nfes/pc-home/*/default/image/group.png"
          />
          <span>当季热卖 · 跟团游</span>
        </div>
        <div class="follow-list">
          <ul>
            <li v-for="(item, ind) in followList" :key="ind">
              <div class="li-box">
                <i class="travel-sort">{{ ind + 1 }}</i>
                <img class="travel-image" :src="item.imgUrl" alt="" />
                <div class="travel-title">
                  <span class="title">{{ item.mainName }}</span>
                  <span class="productScore"
                    >{{ item.productScore }}分 |
                    <i>{{ item.persons }}人出游</i></span
                  >
                </div>
                <div class="travel-price">
                  ￥<i class="price">{{ item.price }}</i
                  >起
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
      <div class="aircraft">
        <div class="header">
          <img
            src="https://webresource.c-ctrip.com/ares2/nfes/pc-home/*/default/image/flight.png"
          />
          <span>周末畅游 · 特价机票</span>
        </div>
        <div class="follow-list">
          <ul>
            <li v-for="(item, ind) in flightsList" :key="ind">
              <div class="li-box">
                <img class="travel-image" :src="item.imgUrl" alt="" />
                <div class="travel-title">
                  <span class="flight-title"
                    >{{ item.departCity }} <el-icon><Switch /></el-icon>
                    {{ item.arriveCity }}</span
                  >
                  <span class="flight-tag">某程精选</span>
                  <span class="productDate"
                    >{{ item.departDate }} 去 {{ item.returnDate }} 回</span
                  >
                </div>
                <div class="travel-price">
                  ￥<i class="price">{{ item.price }}</i>起
                  <div class="rebate">{{ item.rebate }}</div>
                </div>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import { Switch } from "@element-plus/icons-vue";
import { getHotTravels, getHotFlights } from "@/api/home";

let followList: any = ref([]);
let flightsList: any = ref([]);

const getHotTravelsByCity = async () => {
  const res = await getHotTravels({ cityId: 1 });
  followList.value = res;
};

const getHotFlightsByCity = async () => {
  const res = await getHotFlights({ cityId: 1 });
  flightsList.value = res;
};

onMounted(async () => {
  await getHotTravelsByCity();
  await getHotFlightsByCity();
});
</script>

<style scoped lang="scss">
.hotArea {
  margin-top: 28px;
  .card-title {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    .title-font{
      font-size: 24px;
    }
    .orange {
      color: #ff7700;
    }
  }
  .top5 {
    display: flex;
    height: 548px;
    .follow {
      flex: 1;
      margin-right: 5px;
      // border: 1px solid ;
      background: linear-gradient(-153.43deg, #f4fafd 0%, #e2f2fb 100%);
      border-radius: 10px;
      padding: 5px;
      padding-top: 0;
      box-sizing: border-box;
    }
    .aircraft {
      flex: 1;
      margin-left: 5px;
      background: linear-gradient(26.57deg, #e6ecfc 0%, #f4f6fd 100%);
      border-radius: 10px;
      padding: 5px;
      padding-top: 0;
      box-sizing: border-box;
    }
    .header {
      position: relative;
      height: 56px;
      line-height: 56px;
      text-align: center;
      img {
        position: absolute;
        top: 0;
        left: 0;
        width: 96px;
      }
    }
    .follow-list {
      width: 100%;
      height: 487px;
      background-color: #fff;
      position: relative;
      z-index: 1;
      border-radius: 10px;
      padding: 0px 10px;
      box-sizing: border-box;
      ul {
        list-style: none;
        padding: 0;
        margin: 0;
        height: 100%;
        padding-top: 12px;
        display: flex;
        flex-direction: column;
        li {
          flex: 1;
          .li-box{
            display: flex;
            padding-bottom: 2px;
            cursor: pointer;
            position: relative;
            .travel-image{
              border-radius: 5px;
            }
            .travel-sort{
              position: absolute;
              color: #f4f6fd;
              width: 20px;
              border-radius: 0 10px 10px 0;
              background-color: red;
              text-align: center;
            }
            &:hover{
            box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.12);
          }
          }
          
          img {
            display: inline-block;
            width: 80px;
            height: 80px;
            margin-right: 8px;
          }
          .travel-title {
            display: flex;
            flex-direction: column;
            margin-right: 10px;
            flex: 1;
            .title {
              font-weight: bold;
              overflow: hidden;
              text-overflow: ellipsis;
              display: -webkit-box;
              -webkit-line-clamp: 2;
              overflow: hidden;
              -webkit-box-orient: vertical;
            }
            .productScore {
              font-size: 12px;
              color: #0086f6;
              line-height: 24px;
              i {
                color: #666;
              }
            }
          }
          .travel-price {
            display: inline-block;
            text-align: right;
            color: #0086f6;
            font-size: 12px;
            .price {
              font-size: 16px;
              font-weight: bold;
            }
          }
          .flight-title {
            font-weight: bold;
            display: flex;
            align-items: center;
            .el-icon {
              margin: 0 10px;
            }
          }
          .flight-tag {
            font-size: 12px;
            padding: 2px;
            border: 1px solid #bfeddd;
            color: #00b87a;
            width: 55px;
            text-align: center;
            margin-top: 3px;
          }
          .productDate{
            font-size: 12px;
            line-height: 24px;
          }
          .rebate{
            color: #666;
            font-size: 12px;
          }
        }
      }
    }
  }
}
</style>
